package com.kws.system.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kws.common.core.domain.R;
import com.kws.common.security.annotation.InnerAuth;
import com.kws.system.domain.info.QueryLogisticsDetailsInfo;
import com.kws.system.domain.info.QueryLogisticsScheduleInfo;
import com.kws.system.domain.vo.QueryLogisticsScheduleRq;
import com.kws.system.service.LogisticsScheduleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <b>LogisticsScheduleController</b>
 *
 * @description: LogisticsScheduleController <br>
 * @date: 2024/11/22 10:30 <br>
 * @author: lhm <br>
 * @version: 1.0 <br>
 */

@Api(tags = "物流进度管理模块")
@RestController
public class LogisticsScheduleController {
    private static final Logger logger = LoggerFactory.getLogger(LogisticsScheduleController.class);

    @Autowired
    private LogisticsScheduleService logisticsScheduleService;

    @ApiOperation("分页查询物流进度列表")
    @PostMapping("/query/logisticsSchedule/page")
    public R<Page<QueryLogisticsScheduleInfo>> queryLogisticsSchedulePage(@RequestBody QueryLogisticsScheduleRq rq){
        Page<QueryLogisticsScheduleInfo> pageInfo = logisticsScheduleService.queryLogisticsSchedulePage(rq);
        return R.ok(pageInfo);
    }

    @InnerAuth
    @ApiOperation("同步订单物流状态")
    @GetMapping("/gain/logisticsStatus")
    public void gainLogisticsStatus(){
        logisticsScheduleService.gainLogisticsStatus();
    }

    @ApiOperation("根据ID查询物流详情")
    @GetMapping("/querylogisticsDetails/byId")
    public R<QueryLogisticsDetailsInfo> queryLogisticsDetailsById(@RequestParam Long id){
        QueryLogisticsDetailsInfo info = logisticsScheduleService.queryLogisticsDetailsById(id);
        return R.ok(info);
    }
}
